import unittest

from api.employee import employeeAPI

from utils import common_assert


class testEmployee(unittest.TestCase):
    # employee_id = None
    employee_id = 1375333118654894080

    def setUp(self):
        self.employee_api = employeeAPI()


    def tearDown(self) -> None:
        pass


    def test01_add_employee(self):

        add_employee_data = {
            "username": "jack0709t00",
            "mobile": "13456789016",
            "timeOfEntry": "2020-07-09",
            "formOfEmployment": 1,
            "workNumber": "10086",
            "departmentName": "销售",
            "departmentId": "1266699057968001024",
            "correctionTime": "2020-07-30T16:00:00.000Z"
}
        response = self.employee_api.add_employee(add_employee_data)
        print(response.json())
        common_assert(self, response)

        testEmployee.employee_id = response.json().get("data").get("id")

    def test02_update_employee(self):

        add_employee_data = {
            "username": "rose0719"
        }
        response = self.employee_api.update_employee(employee_id=testEmployee.employee_id, update_data=add_employee_data)
        print(response.json())

        common_assert(self, response)


    def test03_get_employee(self):

        response = self.employee_api.get_employee(employee_id=testEmployee.employee_id)
        print(response.json())

        common_assert(self, response)


    def test04_delete_employee(self):

        response = self.employee_api.delete_employee(employee_id=testEmployee.employee_id)
        print(response.json())

        common_assert(self, response)

